local skill = fk.CreateSkill {
  name = "#ling__vine_skill",
  tags = { Skill.Compulsory },
  attached_equip = "ling__vine",
}

skill:addEffect(fk.PreCardEffect, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return data.to == player and player:hasSkill(skill.name) and
      table.contains({"slash", "savage_assault", "archery_attack", "ling__savage_assault"}, data.card.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/maneuvering/audio/card/vine")
    room:setEmotion(player, "./packages/maneuvering/image/anim/vine")
    data.nullified = true
    room:addPlayerMark(player, "@!!ling__vine", 1)
    if player:getMark("@!!ling__vine") > 2 then
      local cards = table.filter(player:getEquipments(Card.SubtypeArmor), function (id)
        return Fk:getCardById(id).name == skill.attached_equip
      end)
      if #cards > 0 then
        room:throwCard(cards, skill.name, player, player)
      end
    end
  end,
})

skill:addEffect(fk.DamageInflicted, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and data.damageType == fk.FireDamage
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/maneuvering/audio/card/vineburn")
    room:setEmotion(player, "./packages/maneuvering/image/anim/vineburn")
    data:changeDamage(1)
  end,
})

return skill
